/*********************************************************
 *  Copyright (c) 2011 by Web Information Systems (WIS) Group, 
 *  Delft University of Technology.
 *  Qi Gao, http://wis.ewi.tudelft.nl/index.php/home-qi-gao
 *  
 *  Some rights reserved.
 *
 *  Contact: q.gao@tudelft.nl
 *
 **********************************************************/
package org.persweb.genius.data;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;

import org.persweb.genius.model.Filter;
import org.persweb.genius.model.Item;
import org.persweb.genius.model.ItemImpl;

/**
 * @author Qi Gao <a href="mailto:q.gao@tudelft.nl">q.gao@tudelft.nl</a>
 * @version created on Oct 25, 2011 3:35:30 PM
 */
public class SimpleItemsFetcherFromFile implements ItemsFetcher {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.persweb.genius.data.ItemsFetcher#getItems()
	 */
	@Override
	public List<Item> getItems() {
		// StringBuffer sb=new StringBuffer("");
		List<Item> items = new ArrayList<Item>();
		try {
			FileReader reader = new FileReader("data/simple-example.txt");
			BufferedReader br = new BufferedReader(reader);
			String s = null;
			while ((s = br.readLine()) != null) {
				items.add(new ItemImpl(s));
			}
			br.close();
			reader.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return items;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.persweb.genius.data.ItemsFetcher#getItems(org.persweb.genius.model
	 * .Filter)
	 */
	@Override
	public List<Item> getItems(Filter filter) {
		// TODO this implementation does not support filter
		return null;
	}

}
